/**
 * Licensed under the MIT License
 *
 * Copyright (c) 2012 Gary Paluk, http://www.plugin.io
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

package io.plugin.blib.gfx 
{
	import io.plugin.core.IDisposable;
	
	/**
	 * ...
	 * @author Gary Paluk - http://www.plugin.io
	 */
	public class BlibTile 
	{
		
		private var _tileX: int;
		private var _tileY: int;
		private var _tileSet: BlibTileSet;
		private var _mapCode: int;
		private var _bounds: int;
		
		//TODO interfaces and bounds
		public function BlibTile( tileset: BlibTileSet = null, x: int = 0, y: int = 0 ) 
		{
			_tileX = x;
			_tileY = y;
			_tileSet = tileset;
			_bounds = BlibTileBounds.NONE;
		}
		
		// TODO 
		public function draw( x: Number, y: Number, width: Number, height: Number, hotspotX: Number, hotspotY: Number,
							  rotation: Number, scaleX: Number, scaleY: Number, tint: uint ): void
		{
			if ( _tileSet == null )
			{
				return;
			}
			if ( tint <= 0 )
			{
				return;
			}
			
		}	
		
		public function get bounds():int 
		{
			return _bounds;
		}
		
		public function set bounds(value:int):void 
		{
			_bounds = value;
		}
		
		public function get leftBoundry(): Boolean
		{
			return ( ( bounds & BlibTileBounds.LEFT ) == BlibTileBounds.LEFT );
		}
		
		public function get bottomBoundry(): Boolean
		{
			return ( ( bounds & BlibTileBounds.BOTTOM ) == BlibTileBounds.BOTTOM );
		}
		
		public function get rightBoundry(): Boolean
		{
			return ( ( bounds & BlibTileBounds.RIGHT ) == BlibTileBounds.RIGHT );
		}
		
		public function get topBoundry(): Boolean
		{
			return ( ( bounds & BlibTileBounds.TOP ) == BlibTileBounds.TOP );
		}
		
		public function get tileX():int 
		{
			return _tileX;
		}
		
		public function set tileX(value:int):void 
		{
			_tileX = value;
		}
		
		public function get tileY():int 
		{
			return _tileY;
		}
		
		public function set tileY(value:int):void 
		{
			_tileY = value;
		}
		
		public function get tileSet():BlibTileSet 
		{
			return _tileSet;
		}
		
		public function set tileSet(value:BlibTileSet):void 
		{
			_tileSet = value;
		}
		
		public function get mapCode():int 
		{
			return _mapCode;
		}
		
		public function set mapCode(value:int):void 
		{
			_mapCode = value;
		}
		
		public function quickDraw( x: Number = 0, y: Number = 0 ): void
		{
			if ( _tileSet != null )
			{
				_tileSet.quickDraw( tileX, tileY, x, y );
			}
			
		}
		
		public function update(): void
		{
			// virtual method
		}
		
	}

}